package cn.wsalix.templet.entity;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import cn.anlaser.entity.SimpleEntity;

/**
 * @author jskyme 模板实体
 */
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "PRO_SITE_TEMPLET")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@EntityListeners({ AuditingEntityListener.class })
@Data
@EqualsAndHashCode(callSuper = false)
public class ProSiteTemplet extends SimpleEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7812490876045784063L;
	private String proSiteCode;//site or admin
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_PST_PROJECT"), name = "PROJECT_ID")
	private Project project;
	
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_PST_SITE"), name = "SITE_ID")
	private SiteInfo siteInfo;
	@Transient
	private Long siteId;
	@ManyToOne(cascade=CascadeType.MERGE,optional=false,fetch=FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_PST_SITETEMP"), name = "SITE_TEMP_ID")
	private SiteTemplet siteTemplet;
	@Transient
	private Long siteTempletId;
	
}
